package leetcode.new_wrold;

import utils.tree.TreeNode;

public class T108 {
    public TreeNode sortedArrayToBST(int[] nums) {
        return subtreeRoot(nums,0,nums.length-1);
    }

    public TreeNode subtreeRoot(int[] nums,int left,int right){
        if (left>right){
            return null;
        }
        int mid = (left+right)/2;

        TreeNode treeNode = new TreeNode(nums[mid]);
        treeNode.left = subtreeRoot(nums,left,mid-1);
        treeNode.right = subtreeRoot(nums,mid+1,right);
        return treeNode;
    }

}
